//
//  BiaoQianViewController.m
//  1gene
//
//  Created by 1jiyin on 16/3/23.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "BiaoQianViewController.h"

@interface BiaoQianViewController ()
@property(nonatomic,copy)NSArray *dataArray;
@end

@implementation BiaoQianViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    self.view.backgroundColor=[UIColor colorWithRed:89/255.0 green:187/255.0 blue:215/255.0 alpha:1];
    [self.view addSubview:[UIView new]];
    [self createNavigation];
    [self createUI];
    // Do any additional setup after loading the view.
}
-(void)createUI
{
    NSLog(@"得到的所有标签%@",_allBiaoQianArray);
    CGFloat lab_w=(self.view.frame.size.width-15*3)/2.0;
    CGFloat lab_h=30;
    NSInteger hang=[self calculatingHang:_allBiaoQianArray.count];
    for (int i=0; i<hang; i++) {
        for (int j=0; j<2; j++) {
            if (i*2+j<_allBiaoQianArray.count) {
                    UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(15+(15+lab_w)*j, 20+44+20+(10+lab_h)*i, lab_w, lab_h)];
                    lab.text=_allBiaoQianArray[i*2+j];
                    lab.textColor=[UIColor whiteColor];
                    lab.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
                    lab.font=[UIFont systemFontOfSize:15];
                    lab.textColor=[UIColor whiteColor];
                    lab.textAlignment=NSTextAlignmentCenter;
                    //lab.backgroundColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1];
                    [self.view addSubview:lab];
            }
        }
    }


}
-(void)createNavigation
{
    self.navigationController.navigationBar.hidden=NO;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    //标题
    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    title.text=@"所有标签";
    title.font=[UIFont systemFontOfSize:22];
    title.textAlignment=NSTextAlignmentCenter;
    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=title;
}
//返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    if (_myTabBarState==1) {
        self.tabBarController.tabBar.hidden=YES;
    }else{
        self.tabBarController.tabBar.hidden=NO;
    }
    self.navigationController.navigationBar.hidden=YES;
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)calculatingHang:(NSInteger)number
{
    NSInteger hang;
    if (number%2==0) {
        hang=number/2;
    }else{
        hang=number/2+1;
    }
    return hang;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
@end
